package com.zly;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

public class CondExprHandler {
    //处理Json字符串条件表达式，符号包含逻辑运算符&&，||，以及括号()

    private static final String AND_OPERATOR = "&&";
    private static final String OR_OPERATOR = "||";
    private static final String LEFT_BRACKET = "(";
    private static final String RIGHT_BRACKET = ")";

    private static final ObjectMapper mapper = new ObjectMapper();

    //构造
    private CondExprHandler(){}

    //对条件表达式求值
    public static boolean evaluate(String condExpr){

        return false;

    }

    //对条件表达式中的一个元素求值（如 a && b，a和b都是元素）
    private static boolean evaluateSingleElem(String elemString){

        JsonNode elemNode = null;{
            try {
                elemNode = mapper.readTree(elemString);
            } catch (JsonProcessingException e) {
                throw new RuntimeException(e);
            }
        }

        return DJUtils.isTruthy(elemNode);

    }

}
